package com.liuyz;

import java.util.Hashtable;
import java.util.LinkedHashSet;
import java.util.TreeSet;
import java.util.Vector;

public class Test {

    static Vector<Cat> vector = new Vector<>();

    static Hashtable<String, Cat> table = new Hashtable<>();

    public static void main(String[] args) {
        // 不会用多个线程去创建多个线程对象
        // 都是一个线程去创建多个线程对象
        // 再交由线程池处理
        for (int i = 1; i <= 20000; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Cat cat = new Cat(Thread.currentThread().getName(), 1, "1");
                    vector.add(cat);
                    table.put(Thread.currentThread().getName(), cat);
                }
            }, i + "").start();
        }


        System.out.println(vector.size());
        System.out.println(table.size());
    }

}
